home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-1.iso / Files / Internet / Web Things / Rtftohtml 2.75.sit / rtftohtml-mac / rtftohtml2.7.5.rsrc / TEXT_1000_Help.txt < prev    next >
Encoding:
Text File  |  1994-11-05  |  22.9 KB  |  593 lines

  1.     1. rtftohtml Users Guide
  2.     2. An Overview of rtftohtml
  3.     3. How it works
  4.     4. What about Graphics?
  5.     5. Special Processing
  6.          1. Making a Named Anchor
  7.          2. Footnote/Endnote Processing
  8.          3. Discarding Unwanted Text
  9.          4. Imbedding HTML in a Document
  10.     6. Customizing rtftohtml
  11.          1. html-trans File Format
  12.               1. .PTag Table
  13.                    1. Sample .PTag Entries
  14.               2. .TTag Table
  15.               3. .PMatch Table
  16.                    1. Sample .PMatch Entries
  17.               4. .TMatch Table
  18.                    1. Sample .PTag Entries
  19.          2. Adding Paragraph Styles
  20.          3. Modifying HTML "Paragraph" Markup
  21.          4. Changing SPECIAL Markup
  22.          5. Changing Text Style Markup
  23.          6. Changing Text Translation
  24.     7. Command Line Options
  25.     8. Nested Paragraph Styles
  26.     9. Errors
  27.  
  28.  
  29.  
  30.                              RTFTOHTML USERS GUIDE
  31.                                        
  32.    This document contains directions for using the rtftohtml filter.
  33.    
  34.    There are two ways that the rtftohtml filter may be used. You can take
  35.    existing documents and translate them to HTML, or write new documents
  36.    explicitly for the World Wide Web. This filter should accomodate both
  37.    uses.
  38.    
  39.                            AN OVERVIEW OF RTFTOHTML
  40.                                        
  41.    rtftohtml reads up RTF format documents and translates them to HTML.
  42.    In processing text, the filter chooses HTML markup based on three
  43.    characteristics. These are
  44.     1. The destination of the text. Example destinations are header,
  45.        footer, nootnote, picture.
  46.     2. The paragraph style. Paragraph styles are user-definable entities,
  47.        but some are pre-defined by the word processing package. For
  48.        Microsoft Word (on the Macintosh) examples are "Normal" and
  49.        "heading 1".
  50.     3. The text attributes. Examples of text styles are bold, courier, 12
  51.        point.
  52.        
  53.    
  54.    
  55.    The filter has built-in rules for dealing with destinations. For
  56.    paragraph and text styles, the rules for translation are contained in
  57.    a file called html-trans. By modifying this file, you can train
  58.    rtftohtml to perform the correct translations for your documents. The
  59.    most common change that you will need to make is to add your own
  60.    paragraph styles to html-trans.
  61.    
  62.    
  63.    
  64.    rtftohtml should produce reasonable HTML output for most documents.
  65.    Here is what you can expect:
  66.      * Your output should appear in a file called "xx.html" where "xx" or
  67.        "xx.rtf" was your input file name.
  68.      * Bold, italic and underlined text should appear with <b>,<i> and
  69.        <u> markup
  70.      * Courier font text should appear with <tt> markup
  71.      * Tables will be formatted using <pre> markup (only plain text is
  72.        supported in tables.)
  73.      * Footnotes will appear at the end of your document with hypertext
  74.        links to them.
  75.      * Table of contents, indexes, headers and footers are discarded.
  76.      * All paragraph styles use in your document must appear in the file
  77.        "html-trans". This allows you to create a mapping from any
  78.        paragraph style to any HTML markup. There are many pre-defined
  79.        styles in html-trans, including "heading 1..6". (If a paragraph
  80.        style is not found, a warning will be generated and the text will
  81.        be written to the HTML file with no special markup.)
  82.      * Each graphic in your file will be written out to a separate file.
  83.        The filename will be "xxn.ext" where "xx" or "xx.rtf" was your
  84.        input, "n" is a unique number and "ext" will be either "pict" for
  85.        Macintosh PICT format graphics or "wmf" for Windows Meta-Files
  86.        format graphics. The HTML file will create links to these files,
  87.        using either "<A HREF=" or "<IMG SRC=" links. SINCE most WWW
  88.        browsers do not understand "wmf" or "pict" format files, the link
  89.        will be to xxn.gif. This presumes that you will run some other
  90.        filter to translate your graphic files to gif.
  91.      * Text that is connected with copy/paste-link constructs will
  92.        generate hypertext links.
  93.        
  94.                                  HOW IT WORKS
  95.                                        
  96.    rtftohtml begins by reading html-trans and the character translation
  97.    files. The rest of the processing is a loop of reading your RTF file
  98.    and writing HTML. A high level overview of this loop looks like this:
  99.     1. Read the next character. In doing so, the filter also reads all of
  100.        the RTF markup that specifies the destination, paragraph and text
  101.        styles of the next character.
  102.     2. Process the destination information. Normally, text is destined
  103.        for the "body" of the document. Sometimes, the text belongs in a
  104.        header, footnote or footer. The filter discards any text for
  105.        headers, footers. For a footnote, the filter writes the text at
  106.        the end of the document and generates a link to it.
  107.     3. Process any SPECIAL text styles. The filter compares the text
  108.        style information to see if it matches any entries in the .TMatch
  109.        table (in html-trans). If there is a match and the entry is for
  110.        "_Discard", "_Literal", "_Hot", "_HRef", "_Name" or "_Footnote"
  111.        then the text will be processed accordingly. For example,
  112.        "_Discard" text is discarded and "_Name" text will generate an
  113.        anchor using the text as a name.
  114.     4. If the text was not SPECIAL, process the paragraph style. The
  115.        filter takes the name of the paragraph style and looks it up in
  116.        the list of paragraph styles in html-trans (in the .PMatch table).
  117.        If the paragraph style is not found in the table it uses the first
  118.        entry : "Normal". This entry has a nesting level and the name of
  119.        the HTML "paragraph"[1] markup to use. Using the HTML paragraph"
  120.        markup name, the filter (using the .PTag table) knows what tags to
  121.        generate for the text.
  122.     5. If the text was not SPECIAL, process the text styles again. The
  123.        filter compares the text style information to see if it matches
  124.        any entries in the .TMatch table (in html-trans). In this step, it
  125.        is possible to match more than one entry. For each matched entry
  126.        in the .TMatch table, the filter uses the HTML "text" markup name,
  127.        the filter (using the .TTag table) knows what tags to generate for
  128.        the text.
  129.        
  130.    
  131.    
  132.    Using this process, the filter can generate any HTML markup for any
  133.    combination of paragraph style and text style.
  134.    
  135.                              WHAT ABOUT GRAPHICS?
  136.                                        
  137.    Graphics are imbedded in RTF in either a binary format or an (ASCII)
  138.    hex dump of that binary. I have never seen a binary format graphic - I
  139.    don't think that the filter will process binary correctly. It does
  140.    handle the hex format of graphics, by converting the hex back into
  141.    binary and writing the binary to a file. The file extension is chosen
  142.    by looking at the original type of the graphic. The following list
  143.    shows the file types and their extensions:
  144.    
  145.    Macintosh PICT
  146.           .pict - also, 256 bytes of nulls are prepended to the graphic.
  147.           This is to conform to the PICT file format.
  148.           
  149.    Windows Meta-files
  150.           .meta - ???? Is this ok???
  151.           
  152.    Windows Bit-map
  153.           .bmp - ???? Is this ok???
  154.           
  155.    
  156.    
  157.    In addition, the filter produces a link to the file containing the
  158.    graphic. Now, since the above graphic formats are not very portable,
  159.    the filter assumes that you will convert these files to something more
  160.    useful, like GIF. So the format of the link is:
  161.    
  162.    <a href="basenameN.ext">Click here for a Picture</a>
  163.    
  164.    where
  165.      * basename is the name of the input document (without the .rtf
  166.        extension)
  167.      * N is a unique number (starting at 1)
  168.      * ext is an extension. This defaults to GIF, but can be overidden
  169.        with the -P command line option.
  170.      *
  171.        
  172.    You can also change the link to an IMG form. If you specify the -I
  173.    command line option, all links to graphics will be of the form:
  174.    
  175.    <IMG src="basenameN.ext">
  176.    
  177.    
  178.    
  179.    There is one other special case. If a graphic is encountered when the
  180.    filter is in the process of generating a link, the IMG form of the
  181.    link is used even without the -I command line option.
  182.    
  183.                               SPECIAL PROCESSING
  184.                                        
  185.    In the following discussion of SPECIAL processing, I will assume that
  186.    rtftohtml has not been customized. If it has, the text styles used to
  187.    create special effects may be different.
  188.    
  189. Making a Named Anchor
  190.  
  191.    To make a named anchor, you simply enter the name in the document
  192.    where you would like the anchor to appear. Then format the text using
  193.    Outline and Hidden. Be careful in formatting the text that you format
  194.    ONLY the name - be careful not to format leading and trailing spaces
  195.    or paragraph marks. As an example, if the text - Named Anchor Example
  196.    - were formatted with Outline and Hidden, it would produce the HTML
  197.    output :
  198.    
  199.    <a name="Named Anchor Example"></a>
  200.    
  201.    
  202.    
  203.    To change the formatting that produces named anchors, you need to
  204.    modify the entry in html-trans that specifies "_Name" formatting.
  205.    
  206. Footnote/Endnote Processing
  207.  
  208.    If your RTF document contains footnotes or endnotes, the filter will
  209.    place the text of the footnote at the end of the HTML document. At the
  210.    footnote reference mark, the filter will generate a hypertext link to
  211.    the text of the footnote. This works with either automatically
  212.    numbered footnotes[2], or user supplied footnote reference marks[+] .
  213.    
  214.    This processing has one special requirement. The rtftohtml filter
  215.    requires that footnote reference marks be formatted as Superscript,
  216.    and that NO other text be formatted with Superscript. If your footnote
  217.    reference marks are not formatted as Superscript, you must identify
  218.    some formatting that is unique to footnote reference marks and then
  219.    specify this in html-trans in the entry describing "_Footnote".
  220.    
  221. Discarding Unwanted Text
  222.  
  223.    If you have text that you do not want to appear in the HTML output,
  224.    simply format the text as Hidden and Plain (that is, no underline,
  225.    outline...).
  226.    
  227.    If you wish to modify the formatting that discards text, you need to
  228.    change the entry in html-trans that specifies "_Discard".
  229.    
  230. Imbedding HTML in a Document
  231.  
  232.    Normally, if your RTF document contained the text
  233.    "<cite>hello</cite>", the translator would output this as:
  234.    "<cite>hello</cite>". This ensures that the text would
  235.    appear in your HTML output exactly as it appeared in the original RTF
  236.    document. If, however, you want the <cite></cite> to be interpreted as
  237.    HTML markup, you must format the tags using Hidden and Shadow. The
  238.    filter will then send the tags through without translation.
  239.    
  240.    When the rtftohtml filter produces HTML markup, it keeps track of the
  241.    nesting level of tags to ensure that you don't get something like
  242.    <b><cite>hello</b></cite> which would be incorrect markup. If you
  243.    imbed HTML markup in your document, the filter will NOT be aware of
  244.    it. You must ensure that your markup appears correctly nested.
  245.    
  246.    If you wish to modify the formatting for imbedded HTML, you need to
  247.    change the entry in html-trans that specifies "_Literal".
  248.    
  249.    
  250.    
  251.    
  252.    
  253.                              CUSTOMIZING RTFTOHTML
  254.                                        
  255.    Some customizations of rtftohtml require a little understanding of how
  256.    the filter work, others require a lot. All of the customizations
  257.    involve editing either html-trans or one of the character translation
  258.    files.
  259.    
  260. html-trans File Format
  261.  
  262.    In html-trans there are four tables. They are .PTag, .TTag, .PMatch
  263.    and .TMatch. These tables begin with the name (in column one) and
  264.    continue until the next table starts. All blank lines and lines
  265.    beginning with a '#' are discarded. '#' lines are typically used for
  266.    comments. The tables themselves are composed of records containing a
  267.    fixed number of fields which are separated by commas. The fields are
  268.    either strings (which should be quoted) integers or bitmasks.
  269.    
  270.   .PTAG TABLE
  271.   
  272.    Each entry in the .PTag table describes an HTML paragraph markup. The
  273.    format is:
  274.    
  275.    .PTag
  276.    
  277.    #"name","starttag","endtag","col2mark","tabmark","parmark",allowtext,c
  278.    annest,DelteCol1,fold 
  279.    
  280.    name
  281.           A unique name for this entry. These names are referenced in the
  282.           .PMatch table.
  283.           
  284.    starttag
  285.           This string will be output once at the beginning of any text
  286.           for this markup.
  287.           
  288.    endtag
  289.           This string will be output once at the end of any text for this
  290.           markup.
  291.           
  292.    col2mark
  293.           This string will be output in place of the first tab in every
  294.           paragraph (used for lists)
  295.           
  296.    parmark
  297.           This string will be output in place of each paragraph mark.
  298.           (usually <br> or <p>)
  299.           
  300.    allowtext
  301.           If 0, no text markup will be allowed within this markup. (for
  302.           example <pre> or <h1> don't format well if they contain
  303.           additional markup.
  304.           
  305.    cannest
  306.           If 1, other paragraph markup will be allowed to nest within
  307.           this markup. (used for nesting lists)
  308.           
  309.    DeleteCol1
  310.           If 1, all text up to the first tab in a paragraph will be
  311.           deleted. (used to strip out bullets that when going to
  312.           unordered lists (<ul>).
  313.           
  314.    fold
  315.           If 1, the filter will add newlines to the HTML to keep the
  316.           number of characters in a line to less than 80. For <pre> or
  317.           <listing> elements, this should be set to 0.
  318.           
  319.    
  320.    
  321.     Sample .PTag Entries
  322.  
  323. "h1","<h1>\n","</h1>\n","\t","\t","<br>\n",0,0,0
  324.  
  325.    This is a level 1 heading. The "\n" in the start and end-tag fields
  326.    forcesa newline in the HTML markup. Since newlines are ignored in HTML
  327.    (except in <pre>) it's only effect is to make the HTML output more
  328.    readable. There is no difference between the first tab and any other.
  329.    They both translate to a tab mark. Paragraph marks generate "<br>"
  330.    followed by a newline (just for looks). Text markup (like <b>) is not
  331.    allowed within <h1> text, because we leave that up to the HTML client.
  332.    No nesting is allowed - (see the discussion on nested styles). No text
  333.    is deleted.
  334.  
  335.  
  336. "Normal","","\n","\t","\t","<p>\n",1,0,0
  337.  
  338.    This is the default for normal text. Regular text in HTML has no
  339.    required start and end-tags. The "\n" in the end-tag field forces a
  340.    newline in the HTML markup. Since newlines are ignored in HTML (except
  341.    in <pre>) it's only effect is to make the HTML output more readable.
  342.    There is no difference between the first tab and any other. They both
  343.    translate to a tab mark. Paragraph marks generate "<p>" followed by a
  344.    newline (just for looks). Text markup (like <b>) is allowed within
  345.    Normal text. No nesting is allowed - (see the discussion on nested
  346.    styles). No text is deleted.
  347.  
  348.  
  349. "ul","<ul>\n<li>","</ul>","\t","\t","\n<li>",1,1,0
  350.  
  351.    This is the entry for unordered lists. This generates a "<ul>\n<li>"
  352.    at the start of the list and "</ul>/n" at the end. There is no
  353.    difference between the first tab and any other. They both translate to
  354.    a tab mark. Paragraph marks generate "<li>" preceded by a newline
  355.    (just for looks). Text markup (like <b>) is allowed, and this entry
  356.    may be nested - and it allows others to be nested within it. This
  357.    allows nested lists. No text is deleted.
  358.    
  359.  
  360. "ul-d","<ul>\n<li>","</ul>","\t","\t","\n<li>",1,1,1
  361.  
  362.    This entry is identical to the previous except that the DeleteCol1
  363.    field is set to 1. This is used to remove bullets (which really appear
  364.    in the RTF) because we don't want to see them in the HTML.
  365.    
  366.   .TTAG TABLE
  367.   
  368.    Each entry in the .TTag table describes an HTML text markup. The
  369.    format is:
  370.    
  371.    .TTag
  372.    
  373.    "name","starttag","endtag" 
  374.    
  375.    name
  376.           A unique name for this entry. These names are referenced in the
  377.           .PMatch table.
  378.           
  379.    starttag
  380.           This string will be output once at the beginning of any text
  381.           for this markup.
  382.           
  383.    endtag
  384.           This string will be output once at the end of any text for this
  385.           markup.
  386.           
  387.    Note that unlike the .PTag table, no text markup should appear more
  388.    than once. (Of course there is no good reason that it should appear.)
  389.    If you have two entries with <b></b> start and end tags, it would be
  390.    possible to get HTML of the form <b><b> text</b></b>. I don't know if
  391.    this is invalid markup, but it sure is ugly.
  392.    
  393.   .PMATCH TABLE
  394.   
  395.    Each entry in the .PMatch correlates a paragraph style name to some
  396.    entry in the .PTag table. The format is:
  397.    
  398.    .PMatch
  399.    
  400.    "Paragraph Style",nesting_level,"PTagName" 
  401.    
  402.    Paragraph Style
  403.           The paragraph style name that appears in the RTF input.
  404.           
  405.    nesting_level
  406.           The nesting level. This should be zero except for nested list
  407.           entries.
  408.           
  409.    PTagName
  410.           The name of the .PTag entry that should be used for paragraphs
  411.           with this paragraph style.
  412.           
  413.    
  414.    
  415.     Sample .PMatch Entries
  416.  
  417. "heading 1",0,"h1"
  418.  
  419.    This is a level 1 heading. Any paragraphs with this paragraph style
  420.    will be mapped to the entry in the .PTag table named "h1".
  421.  
  422.  
  423. "numbered list",0,"ol-d"
  424.  
  425.    This is used for numbered lists. Any paragraphs with this paragraph
  426.    style will be mapped to the entry in the .PTag table named "ol-d".
  427.  
  428.  
  429. "numbered list 2",2,"ol-d"
  430.  
  431.    This is an entry for a nested paragraph style. The nesting level of
  432.    two is used to indicate that this paragraph should appear in the HTML
  433.    nested within two levels of paragraph markups. The paragraph marked
  434.    with this style may only appear after a paragraph style that has a
  435.    nesting level of 1 or greater.
  436.  
  437.  
  438.   .TMATCH TABLE
  439.   
  440.    Each entry in the .TMatch table describes processing for text styles.
  441.    The format is:
  442.    
  443.    .TMatch
  444.  
  445. "Font",FontSize,Match,Mask,"TextStyleName"
  446.  
  447.  
  448.    Font
  449.           The name of a Font, or "" if all fonts match this entry.
  450.           
  451.    FontSize
  452.           The point-size of the font, or 0 if all point sizes match this
  453.           entry.,
  454.           
  455.    Match
  456.           A bit-mask, where each bit represents a text attribute. These
  457.           bits are compared to the attributes of the style being output.
  458.           They must match for this entry to be matched. One in a bit
  459.           position means that the text style is set, a zero is not set.
  460.           
  461.    Mask
  462.           A bit-mask, where each bit represents a text attribute. In
  463.           comparing the style of the text being processed, to the Match
  464.           bit-mask, this field is used to select the bits that matter. If
  465.           a zero appears in a bit-position, then that style attribute is
  466.           ignored (for the purpose of matching this entry.) Only 1 bits
  467.           are used in the above comparision.
  468.           
  469.    TextStyleName
  470.           This is either the name of an entry in the .TTag table
  471.           indicating the HTML markup to use, or it is one of "_Discard",
  472.           "_Name", "_HRef", "_Hot", or "_Literal".
  473.           
  474.  
  475. The order of bits in the Match and Mask bit-maps are:
  476. #    v^bDWUHACSOTIB - Bold
  477. #    v^bDWUHACSOTI - Italic
  478. #    v^bDWUHACSOT - StrikeThrough
  479. #    v^bDWUHACSO - Outline
  480. #    v^bDWUHACS - Shadow
  481. #    v^bDWUHAC - SmallCaps
  482. #    v^bDWUHA - AllCaps
  483. #    v^bDWUH - Hidden
  484. #    v^bDWU - Underline
  485. #    v^bDW - Word Underline
  486. #    v^bD - Dotted Underline
  487. #    v^b - Double Underline
  488. #    v^ - SuperScript
  489. #    v - SubScript
  490.  
  491.    
  492.    
  493.     Sample .PTag Entries
  494.  
  495. # double-underline/not hidden -> hot text
  496. # double-underline/hidden -> href
  497. #    v^bDWUHACSOTIB,v^bDWUHACSOTIB
  498. "",0,00100000000000,00100010000000,"_Hot"
  499. "",0,00100010000000,00100010000000,"_HRef"
  500.  
  501.    The first entry will match any text formatted with double underline
  502.    EXCEPT if it is hidden text. This is accomplished by using those two
  503.    bits to compare (the MASK field) and having a 1 in the double
  504.    underline bit and a zero for the hidden text bit. The second entry
  505.    will match any text formatted with BOTH double underline and hidden
  506.    text. Any text that matches the first will be treated as the hot text
  507.    of a link. Any text that matches the second will be taken as the href
  508.    itself. (The filter requires that the HRef text immediately precede
  509.    the Hot text.)
  510.    
  511.  
  512. # Regular matches - You can have multiple of these active
  513. # monospace fonts -> tt
  514. "Courier",0,00000000000000,00000000000000,"tt"
  515.  
  516.    This will match any text that uses the Courier font and mark it using
  517.    the HTML text markup appearing in the .TTag table with the entry name
  518.    "tt".
  519.    
  520.  
  521. # bold -> bold
  522. #    v^bDWUIACSOTIB,v^bDWUIACSOTIB
  523. "",0,00000000000001,00000000000001,"b"
  524.  
  525.    This will match any text that has bold attributes and will mark it
  526.    using the HTML text markup appearing in the .TTag table with the entry
  527.    name "b". Note that bold text using the Courier font would match both
  528.    this entry and the previous. This will yeild markup of the form
  529.    <b><tt>hi</tt><b>. Note that "b" is the name of an entry in the .TTag
  530.    table, not the HTML markup that is used!
  531.    
  532. Adding Paragraph Styles
  533.  
  534.    To add a new paragraph style, simply go to the .PMatch table and add
  535.    an entry to the end. Put the name of the paragraph style (quoted), the
  536.    nesting level (usually zero) and the name of the .PTag entry that
  537.    should be used.
  538.    
  539. Modifying HTML "Paragraph" Markup
  540.  
  541.    This section in progress
  542.    
  543. Changing SPECIAL Markup
  544.  
  545.    This section in progress
  546.    
  547. Changing Text Style Markup
  548.  
  549.    This section in progress
  550.    
  551. Changing Text Translation
  552.  
  553.    This section in progress
  554.    
  555.                              COMMAND LINE OPTIONS
  556.                                        
  557.    The syntax of the rtftohtml command is as follows:
  558.  
  559. rtftohtml [-i] [-o filename] [-P extension] [file]
  560.  
  561.  
  562.    -i   Indicates that imbedded graphics should be linked into the main
  563.           document using an IMG tag. The default is to use an HREF style
  564.           link.
  565.           
  566.    -o filename
  567.           Indicates that the output file name should be "filename". If
  568.           any other files are created (such as for graphics,) the
  569.           basename of the other files will be "filename" without ".rtf"
  570.           if it is present in the name.
  571.           
  572.    -P extension
  573.           Use "extension" as the extension for any links to graphics
  574.           files. The default for this is "gif".
  575.           
  576.    "file"
  577.           The file name to be processed. If no file is given, standard
  578.           input is used. If standard input is used, the body of the
  579.           document will be written to standard output (unless overridden
  580.           by the -o option.) If a file name appears, the output is
  581.           written to "filename" with ".html" as an extension. (If ".rtf"
  582.           appears as an extension on the original input file, it is
  583.           stripped before appending the ".html")
  584.           
  585.                             NESTED PARAGRAPH STYLES
  586.                                        
  587.    This section in progress
  588.    
  589.                                     ERRORS
  590.                                        
  591.    This section in progress
  592.  
  593.